const GBK = require('gbk.js')

function getEncodeURI (str, char) {
  if (char === 'gbk') {
    return GBK.URI.encodeURI(str)
  }
  return encodeURI(str)
}

function getEncodeURIComponent (str, char) {
  if (char === 'gbk') {
    return GBK.URI.encodeURIComponent(str)
  }
  return encodeURIComponent(str)
}

function decode (buf, char) {
  if (char === 'gbk') {
    return GBK.decode(buf)
  }
  return buf
}

function encode (str, char) {
  if (char === 'gbk') {
    return GBK.encode(str)
  }
  return Buffer.from(str)
}

module.exports = {
  getEncodeURI,
  getEncodeURIComponent,
  encode,
  decode
}
